package com.wehealth.util;

import java.util.Random;

public class VerifyCode {
    
    private static final int DEFAULT_CODE_LENGTH = 4; 
    private Random random = new Random();
    private static final char[] CHARS = {  
           '0','1','2', '3', '4', '5', '6', '7', '8', '9'
//        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm',   
//        'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',  
//        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',   
//        'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'  
    }; 
    
    private static VerifyCode mCode;  
    
    public static VerifyCode getInstance() {  
        if(mCode == null)  
            mCode = new VerifyCode();  
        return mCode;  
    }  
    
    public String createCode() {  
        StringBuilder buffer = new StringBuilder();  
        for (int i = 0; i < DEFAULT_CODE_LENGTH; i++) {  
            buffer.append(CHARS[random.nextInt(CHARS.length)]);  
        }  
        return buffer.toString();  
    }  
    
}
